package com.chen.authority.common.response;

import cn.hutool.http.HttpStatus;
import com.chen.authority.common.constant.SysConstant;

/**
 * 单一响应
 *
 * @author chengy
 * @date 2022/09/27
 */
public class SingleResponse<T> extends Response {

    /**
     * 响应数据
     */
    private T data;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    /**
     * 成功响应
     *
     * @param data 数据
     * @param <T>  数据类型
     * @return 单一响应
     */
    public static <T> SingleResponse<T> success(T data) {
        SingleResponse<T> singleResponse = new SingleResponse<>();
        singleResponse.setCode(HttpStatus.HTTP_OK);
        singleResponse.setMessage(SysConstant.SUCCESS_MSG);
        singleResponse.setData(data);
        return singleResponse;
    }

}
